# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=unfs3
pkgver=0.9.22
pkgrel=6
pkgdesc="user-space implementation of the NFSv3 server specification"
options="!check" # No testsuite
url="http://unfs3.sourceforge.net/"
arch="all"
license="BSD-3-Clause"
depends="rpcbind"
makedepends="flex-dev libtirpc-dev byacc"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://downloads.sourceforge.net/unfs3/unfs3-$pkgver.tar.gz
	unfs3-0.9.22-musl.patch
	gcc-10.patch
	fix-tcp.patch
	unfs3.confd
	unfs3.initd
	"

build() {
	# -fcommon is required because of multiple definitions without extern
	# from a type generated by yacc
	export CFLAGS="$CFLAGS -fcommon $(pkgconf --cflags libtirpc)"
	export LDFLAGS="$LDFLAGS $(pkgconf --libs-only-L libtirpc)"
	export LIBS="$LIBS $(pkgconf --libs-only-l libtirpc)"

	sed -i '/LDFLAGS=/ s,-R/usr/ucblib,,' ./configure

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make -j1
}

package() {
	make DESTDIR="$pkgdir/" install
	install -D -m0644 "$srcdir"/unfs3.confd "$pkgdir"/etc/conf.d/unfs3
	install -D -m0755 "$srcdir"/unfs3.initd "$pkgdir"/etc/init.d/unfs3
}

sha512sums="
b1e4b7f5b7b7de27bb5411c69363a6b40be0fcf1f772e283f0868a2155fa9ea4b9b8e7f05b1706e41cf09dd2ee4baab472a01bc4640ae47e3be2a19d8d3f5f9e  unfs3-0.9.22.tar.gz
f2221651fad842acb8b5fd637514caa07300f627efd5b168ee2939ab3b6ea55fdefa3c3f3336425e255ee7badd326528c722d4064a04936b5468aabc79cbca02  unfs3-0.9.22-musl.patch
133a80a0e03281ab95f584a8b5f930dba07614e31d2dddbb63e62d793828aece2090014b4c635ffe101e6257f1b8d158fb4d115e6452a1490cbd338f3b13c58c  gcc-10.patch
af189b45ef26aede0899f1073b130ba4675811a5acebef95fd75adbcd20a8b8be33cac2d2d00164195df62fc5907c97ab2c0aa8927089597b5bd81e53a3829d1  fix-tcp.patch
e3a3b7a71117482fd3214eadfd957f5cd3f05da268f748f931945c390f1d8e46e19b33d53b2ce0505c61745f8dd6285f7a9de409196fedef07d23ae029f1c035  unfs3.confd
105b1ac6d0a65b3ba19bb8ada17d1ae865cf14e71e6a3838df1e6d34d2738457f0019258fd10a4594783074c10be44db75417677290bdd6862ba73b4c370b07e  unfs3.initd
"
